package com.mingyuan.library.domain.lending.patron.event;

import com.mingyuan.library.domain.lending.book.model.valueobject.BookId;
import com.mingyuan.library.domain.lending.librarybranch.model.valueobject.LibraryBranchId;
import com.mingyuan.library.domain.lending.patron.model.valueobject.PatronId;
import lombok.NonNull;
import lombok.Value;

import java.time.Instant;
import java.util.UUID;

/**
 * 预定超期事件
 */
@Value
public class BookHoldExpired implements PatronEvent {
    @NonNull
    UUID eventId = UUID.randomUUID();
    @NonNull
    Instant when;
    @NonNull
    UUID patronId;
    @NonNull
    UUID bookId;
    @NonNull
    UUID libraryBranchId;

    public static BookHoldExpired now(BookId bookId, PatronId patronId, LibraryBranchId libraryBranchId) {
        return new BookHoldExpired(
                Instant.now(),
                patronId.getPatronId(),
                bookId.getBookId(),
                libraryBranchId.getLibraryBranchId());
    }
}